package com.xinsilu.hospital.controller;

import com.xinsilu.common.Result;
import com.xinsilu.hospital.entity.Listofnoninpatientdrugs;
import com.xinsilu.hospital.entity.Listofnoninpatientitems;
import com.xinsilu.hospital.entity.NoHospitalizationTable;
import com.xinsilu.hospital.service.IListofnoninpatientdrugsService;
import com.xinsilu.hospital.service.IListofnoninpatientitemsService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/hospital/listofnoninpatientitems")
public class ListofnoninpatientitemsController {
    @Autowired
    private IListofnoninpatientitemsService ls;

    @PostMapping("/addxm")
    public Object addyaopin(Listofnoninpatientitems listofnoninpatientitems){
        boolean save = ls.save(listofnoninpatientitems);
        if(save){
            return Result.ok("成功");
        }
        return Result.ok(save);
    }

    @RequestMapping("/getgoumai")
    public Object getgoumai(Listofnoninpatientitems listofnoninpatientitems){


        List<Listofnoninpatientitems> getgoumai = ls.getgoumai(listofnoninpatientitems);
        return Result.ok(getgoumai);
    }

    @RequestMapping("/getjiancha")
    public Object getjiancha(Listofnoninpatientitems listofnoninpatientitems){


        List<Listofnoninpatientitems> getjiancha = ls.getjiancha(listofnoninpatientitems);
        return Result.ok(getjiancha);
    }

    @PostMapping("/updateqian")
    public Object updateqian(@Param("yishou")String yishou, @Param("patientid")int patientid){

        Integer shouqian = ls.shouqian(yishou,patientid);
        if(shouqian==1){
            return Result.ok("成功");
        }
        return Result.ok(shouqian);
    }

    @PostMapping("/yijiancha")
    public Object yijianhca(@Param("sfjiancha")String sfjiancha, @Param("patientid")int patientid){

        Integer yijiancha = ls.yijiancha(sfjiancha,patientid);
        if(yijiancha==1){
            return Result.ok("成功");
        }
        return Result.ok(yijiancha);
    }
}
